<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="./resources/login.ico">
<script src="./jquery/jquery.min.js"></script>
<script src="./bootstrap/js/bootstrap.min.js"></script>
<script src="./login.js"></script>
<title>注册</title>

<!-- Bootstrap core CSS -->
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="./bootstrap/css/login.css" rel="stylesheet">
<!-- video required -->
<script src="./bootstrap/js/Vidage.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../bootstrap/css/htmleaf-demo.css">
<link rel="stylesheet" href="../../bootstrap/css/init.css" />
<link rel="stylesheet" href="../../bootstrap/css/Vidage.css" />
<link rel="stylesheet" href="../../bootstrap/css/jquery.FlowupLabels.css" />
<link rel="stylesheet" href="../../css/register.css" />
</head>

<body>
     <div class="Vidage">
       <div class="Vidage__image"></div>

       <video id="VidageVideo" class="Vidage__video" preload="metadata" loop autoplay>
           <!-- <source src="videos/bg.webm" type="video/webm"> -->
           <source src="resources/videos/bg.mp4" type="video/mp4">
       </video>

       <div class="Vidage__backdrop"></div>
   	</div>
	<div class="container">
		<form class="form-signin">
			<h2 class="form-signin-heading">请注册</h2>
			<div class="custom-input">
				<label for="inputEmail">邮件地址/手机号码</label> 
				<input type="email" id="inputEmail" class="form-control" placeholder="邮件地址/手机号码" required autofocus> 
			</div>
			<div class="custom-input">
				<label for="inputPassword">密码</label> 
				<input type="password" id="inputPassword" class="form-control" placeholder="密码" required> 
			</div>
			<div class="custom-input">
				<label for="confirmPassword">确认密码</label> 
				<input type="password" id="confirmPassword" class="form-control" placeholder="确认密码" required>
		    </div>
		    <div class="form-group">
		    <div class="col-sm-4">
			<button class="btn btn-lg btn-primary btn-block" type="submit"
				onclick="doRegister();">确定</button>
			</div>
			<div class="col-sm-offset-4 col-sm-4">
			<button class="btn btn-lg btn-primary btn-block" type="submit"
				onclick="doCancel();">取消</button>
			</div>
		</form>
		</div>
	</div>
	<!-- /container -->


	<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
	<!-- <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script> -->
</body>
<script type="text/javascript">
	$().ready(function() {

	});

	function doRegister() {
		var email = $("#inputEmail").val();
		var passwd = $("#inputPassword").val();
		var confirmpwd = $("#confirmPassword").val();
		if (0 == email.length || 0 == passwd.length) {
			alert("所填值不能为空");
			return;
		}
		if (passwd != confirmpwd) {
			alert("所注册的密码不一致，请重新输入");
			return;
		}
		var param = {
			email : email,
			passwd : passwd,
			confirmpwd : confirmpwd
		};
		$.ajax({
			type : "POST",
			url : "/registerForm",
			async : false,
			contentType : "application/json",
			data : JSON.stringify(param),
			success : function(result) {
				if ("success" == result) {
					$.ajax({
						type : "GET",
						success : function(data) {
							window.location.href = "/schedule";
						}
					});
				} else {
					alert("注册失败，请重新注册......");
				}

			}
		});
	}
</script>
</html>
